package rin.android.gamble;



import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;

public class Setting extends MyApp implements OnClickListener{
	public static boolean isSound;
    public static boolean isMusic;
    Button button_back;
    CheckBox checkBox_music, checkBox_sound;
    MySharedPreferences mySharedPreferences;
    
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
        setContentView(R.layout.activity_setting);
 
        mySharedPreferences = new MySharedPreferences(this);
        mySharedPreferences.getIsSound();
        mySharedPreferences.getIsMusic();
 
        button_back = (Button) findViewById(R.id.button_back);
        button_back.setOnClickListener(this);
 
        checkBox_music = (CheckBox) findViewById(R.id.checkBox_music);
        checkBox_music.setOnClickListener(this);
        checkBox_music.setChecked(isMusic);
 
        checkBox_sound = (CheckBox) findViewById(R.id.checkBox_sound);
        checkBox_sound.setOnClickListener(this);
        checkBox_sound.setChecked(isSound);
 
    }
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		MainActivity.mSound.playClick();
		switch (v.getId()) {
        case R.id.button_back:
        	this.finish();
        	break;
        case R.id.checkBox_music:
        	isMusic = checkBox_music.isChecked();
        	mySharedPreferences.updateIsMusic(isMusic);
        	break;
        case R.id.checkBox_sound:
        	isSound = checkBox_sound.isChecked();
        	mySharedPreferences.updateIsSound(isSound);
        	break;
		}
	}
	@Override
    public void onBackPressed() {
        MainActivity.mSound.playClick();
        this.finish();
    }
}